package org.evs.odesk.programmingSkills;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Dmitry Kalachov
 * 
 *         Write a program which will accept a single pair of strings separated by a comma; the program should calculate
 *         the sum of ascii values of the characters of each string. The program should then subtract the sum of the
 *         ascii values of the second string from the sum of the ascii values of the first string.
 * 
 *         Suppose the following input is given to the program:
 * 
 *         123ABC,456DEF
 * 
 *         Then the sum of the ascii values of the characters in '123ABC' is 348 and in '456DEF' it is 366. The
 *         Difference between these numbers is 348 – 366 = -18
 *         The corresponding output to be printed by the program is:
 * 
 *         -18
 * 
 */
public class Task_ASCII {

    public static void main(String[] args) throws IOException {
        BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
        String line = consoleReader.readLine();
        String[] strings = line.trim().split(",");

        if (strings.length == 2) {
            String firstValue = strings[0];
            String secondValue = strings[1];

            int firstValueASCII = 0;
            int secondValueASCII = 0;

            char[] firstValueCharacheters = firstValue.toCharArray();
            char[] secondValueCharacheters = secondValue.toCharArray();

            for (char char1 : firstValueCharacheters) {
                firstValueASCII += charToASCII(char1);
            }

            for (char char1 : secondValueCharacheters) {
                secondValueASCII += charToASCII(char1);
            }

            System.out.println(firstValueASCII - secondValueASCII);

        }

    }

    public static int charToASCII(final char character) {
        return (int) character;
    }

}
